import React, { useRef, useState } from 'react';
import { Video, View } from '@tarojs/components'
const VideoPlayer = ({ src, videoRef, isFullScreen, loop, videoKey, videoContext, setPlayerSrc, setIsFullScreen }) => {
    return (
        <View style={{ position: 'absolute', display: isFullScreen ? 'block' : 'none' }}>
            <Video id={videoKey} onFullscreenChange={(e, o) => {
                if (!e.detail.fullScreen) {
                    videoContext.stop()
                    videoContext.exitFullScreen()
                    setPlayerSrc('')
                }
                setIsFullScreen(e.detail.fullScreen)
            }} src={src} loop={loop} autoPlay ref={videoRef} controls>
            </Video>
        </View>
    );
};

export default VideoPlayer;